define(function(require, exports, module) {
	'use strict';
    

    (function () {
        var ctrlNum = 8;
        $.widget('rk.wrStatistics_' + ctrlNum + 'PopupCtrl', $.rk.wrStatisticsPopupCtrl, {
            _create: function () {
                var me = this;
                var elem = me.element;
            },
            _init: function () {
                var me = this;
                me._super();
            },
            _handleData: function (data) {
                var me = this;
                var elem = me.element;

                var salesParameters = data.salesParameters;
                me._buildReasonMap(salesParameters);

                //最后一条数据
                var opportunities = data.opportunities;
                if (opportunities.length > 0)opportunities[opportunities.length - 1].isLast = true;
                for (var i = 0, len = opportunities.length; i < len; i++) {
                    var entity = opportunities[i];
                    var reason = me.reasonMap[entity.reason + ''];
                    entity.reasonText = reason.parameterName;
                }

                return data;
            },
            reasonMap: [],
            _buildReasonMap: function (salesParameters) {//输单理由
                var me = this;
                for (var i = 0, len = salesParameters.length; i < len; i++) {
                    var param = salesParameters[i];
                    me.reasonMap[param.id + ''] = param;
                }
            }
        });
    })()
});
